package com.bkgy.modular.configureRules.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.bkgy.modular.configureRules.dto.KHDegree2130Dto;
import com.bkgy.modular.configureRules.entity.KHDegree2130;
import com.bkgy.modular.configureRules.mapper.KHDegre2130Mapper;
import com.bkgy.modular.configureRules.service.KHDegree2130Service;
import com.bkgy.sys.common.entity.ResultData;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
 * @author
 * @version 1.0
 * @ClassName KHDegree2130ServiceImpl
 * @date 2023/4/19 10:34
 */
@Service
public class KHDegree2130ServiceImpl extends ServiceImpl<KHDegre2130Mapper, KHDegree2130> implements KHDegree2130Service {

    @Resource
    private KHDegre2130Mapper mapper;

    @Override
    public ResultData queryKHDegre2130() {
        List<KHDegree2130> khDegree2130List = mapper.selectList(null);
        return ResultData.ResultDataFaultSelf("操作成功",khDegree2130List);
    }

    @Override
    public ResultData updateKHDegre2130(KHDegree2130Dto dto) {
        Double classid = dto.getClassid();
        if (classid == null) {
            return ResultData.ResultDataFaultSelf("参数有误,请检查参数",-1);
        }
        Double yp_class = dto.getYp_class();
        Double ora_thk_class = dto.getOra_thk_class();
        Double pro_thk_class = dto.getPro_thk_class();
        Double wid_class = dto.getWid_class();
        Double yp_class1 = dto.getYp_class1();

        LambdaQueryWrapper<KHDegree2130> queryWrapper = new LambdaQueryWrapper<>();
        queryWrapper.eq(KHDegree2130::getClassid,classid);

        KHDegree2130 khDegree2130 = mapper.selectOne(queryWrapper);
        khDegree2130.setOra_thk_class(ora_thk_class);
        khDegree2130.setPro_thk_class(pro_thk_class);
        khDegree2130.setWid_class(wid_class);
        khDegree2130.setYp_class1(yp_class1);
        khDegree2130.setYp_class(yp_class);

        int flag = mapper.update(khDegree2130, queryWrapper);
        if (flag == 1) {
            return ResultData.ResultDataFaultSelf("操作成功",1);
        }
        return ResultData.ResultDataFaultSelf("操作失败",-1);
    }
}
